﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class CommanMethods : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    [WebMethod]
    public static List<City> GetCities(String City)
    {
        using (POSEntities db = new POSEntities())
        {
            var cities=(from c in db.Cities where c.City_Name.Contains(City) select c).ToList();
            return cities;
        }
    }
    [WebMethod]
    public static List<Department> GetDepartments()
    {
        using (POSEntities db = new POSEntities())
        {
            var department = (from d in db.Departments where d.BranchId == 1 select d).ToList();
            return department;
        }
    }
    [WebMethod]
    public static List<SubDepartment> GetSubDepartments(int deptId)
    {
        using (POSEntities db = new POSEntities())
        {
            var department = (from d in db.SubDepartments where d.Dept_ID == deptId select d).ToList();
            return department;
        }
    }
    [System.Web.Services.WebMethod]
    public static List<ItemCategory> SearchCategories()
    {
        using (POSEntities db = new POSEntities())
        {
            try
            {
                var category = (from c in db.ItemCategories where c.IsDeleted == false select c).ToList();
                return category;
            }
            catch (Exception ex)
            {
                return null;
            }

        }
    }
}